/*
 * xAPhbeatScheduler.java
 *
 * Java class used to schedule the transmission xAP heart-beat messages
 *
 * Copyright (c) 2009 Daniel Berenguer <dberenguer@usapiens.com>
 *
 * This file is part of the jxAP project.
 *
 * OPNODE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * OPNODE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with canTracer; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 07/11/09 by Daniel Berenguer : first version
 */

package xAP;

import java.util.Timer;
import java.util.TimerTask;


/********************************************************************************************
 * xAPhbeatScheduler class
 *********************************************************************************************/
public class xAPhbeatScheduler
{
   /********************************************************************************************
    * Member variables
    ********************************************************************************************/
    Timer timer;
    xAPHeartBeat hbeatAlive;

   /********************************************************************************************
    * xAPhbeatScheduler
    *
    * Class constructor
    *
    * 'seconds'    Timer period
    *
    ********************************************************************************************/
    public xAPhbeatScheduler(int seconds)
    {
        // xAP heart-beat message
        hbeatAlive = new xAPHeartBeat(true);

        timer = new Timer() ;
        timer.scheduleAtFixedRate(new TimerTask()
        {
            @Override
            public void run()
            {
                // Send xAP heart-beat message
                hbeatAlive.send();
            }
        }, 0, seconds*1000);
    }
}
